import tree_sitter_ming as ts_ming
from tree_sitter import Language, Parser

def new_parser():
    MING_LAN = Language(ts_ming.language())
    parser = Parser(MING_LAN)
    return parser

def parse_file(f):
    parser = new_parser()
    with open(f, 'r') as file:
        code = file.read()
        tree = parser.parse(bytes(code, 'utf-8'))
        return tree

def parse_code(code):
    parser = new_parser()
    tree = parser.parse(bytes(code, 'utf-8'))
    return tree

